package com.kawaiior.asoulworld.property.Properties;

import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.event.entity.living.LivingHurtEvent;

public class PropertyExecute extends PropertyBase implements Iproperty {

    private float [] levelOfValue = new float[]{0.03f,0.06f,0.10f};

    public PropertyExecute(int level) {
        super(level);
    }


    //对当前生命值减去本次伤害数值后小于3%，4%，5%的目标造成极高的真实伤害
    @Override
    public void doProperty(LivingHurtEvent event) {
        if (event.getEntity() instanceof EntityLivingBase){
            float h = ((EntityLivingBase)event.getEntity()).getHealth();
            if (h - event.getAmount() <= h * levelOfValue[this.getLevel()]){
                event.getSource().setDamageBypassesArmor();
                event.setAmount(10000f);
            }
        }
    }

    @Override
    public String getPropertyString() {
        return "property_execute";
    }
}
